//
//  TopMenuController.m
//  iPlanet
//
//  Created by 仁燮 金 on 12/06/06.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "TopMenuController.h"

@implementation TopMenuController

- (id)init {
	if ((self = [super initWithStyle:UITableViewStylePlain])) {
		self.title = @"太陽系一覧";
		items_ = [[NSMutableArray alloc] initWithObjects:@"ViewController", @"水星", @"金星", nil];
	}
	return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	return [items_ count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"simple-cell"];
	if (!cell) {
		cell = [[UITableViewCell alloc] initWithFrame:CGRectZero];
	}
	cell.textLabel.text = [items_ objectAtIndex:indexPath.row];
	return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	Class class = NSClassFromString([items_ objectAtIndex:indexPath.row]);
	id viewController = [[class alloc] init];
	if (viewController) {
		[self.navigationController pushViewController:viewController animated:YES];
	}
}

@end
